package com.cg.service.impl;

import com.cg.entity.Region;
import com.cg.mapper.RegionMapper;
import com.cg.service.RegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地区服务实现类
 */
@Service
@Slf4j
public class RegionServiceImpl implements RegionService {
    
    @Autowired
    private RegionMapper regionMapper;
    
    @Override
    public List<Region> getProvinces() {
        log.info("获取所有省份");
        return regionMapper.getProvinces();
    }
    
    @Override
    public List<Region> getCitiesByProvince(String provinceCode) {
        log.info("根据省份代码获取城市列表，省份代码：{}", provinceCode);
        return regionMapper.getCitiesByProvince(provinceCode);
    }
    
    @Override
    public List<Region> getDistrictsByCity(String cityCode) {
        log.info("根据城市代码获取区县列表，城市代码：{}", cityCode);
        return regionMapper.getDistrictsByCity(cityCode);
    }
    
    @Override
    public Region getByCode(String code) {
        log.info("根据地区代码获取地区信息，地区代码：{}", code);
        return regionMapper.getByCode(code);
    }
    
    @Override
    public List<Region> searchByName(String name) {
        log.info("根据名称搜索地区，名称：{}", name);
        return regionMapper.searchByName(name);
    }
}
